<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ck" uri="http://ckeditor.com"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>我的留言板</title>
<link href="${pageContext.request.contextPath}/css/slider.css"
	rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/common.css"
	rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/index.css"
	rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
	function checkDel() {
		return window.confirm("您确定要删除此留言吗?");
	}
	
	//批量删除
	$(function(){
	    $("#deleteSkills").click(function(){
	        //判断是否至少选择一项
	        var checkedNum = $("input[name='ids']:checked").length;
	        if(checkedNum==0){
	            alert("请至少选择一项");
	            return;
	        }
	        if(confirm("确定要删除所选留言？")){
	            //这个数组存储要删除的数据的id
	            var checkedList = new Array();
	            //每一个被选中的name为ids的input标签
	            $("input[name='ids']:checked").each(function(){
	                checkedList.push($(this).val());//将id存入数组
	            });
	            $.ajax({
	                type:"post",
	                dataType:"json",
	                url:"${pageContext.request.contextPath}/deleteMessage.action",//不同页面只用更改action即可
	                async:true,
	                //数组的toString里的id是用","分隔开的，例如数组{"1","2","3"},同String后为"1,2,3"
	                data:{"deleteList":checkedList.toString()},
	                success:function(data){
	                    if(data==1){
	                        for(var i=0;i<checkedList.length;i++){
	                            $("#tr_"+checkedList[i]).remove();//ajax动态移除
	                        }
	                        alert("删除成功");
	                    }else{
	                        alert("删除失败");
	                    }
	                },
	                error:function(){
	                    alert("error");
	                }
	             })
	         }
	     })
	              			
	})
</script>
</head>
<body>

	<div class="container header">
		<div class="span5">
			<div class="logo">
				<a href="${pageContext.request.contextPath}/index.action"> <img
					src="${pageContext.request.contextPath}/image/r___________renleipic_01/logo.gif"
					alt=""></a>
			</div>
		</div>
		<div class="span9">
			
		</div>
		<%@ include file="menu.jsp"%>
	</div>
	<div class="container cart">
			<table>
				<tr>
					<td class="ta_01" align="center" bgColor="#f5fafe">
						<table cellspacing="0" cellpadding="1" rules="all"
							bordercolor="gray" border="1" id="DataGrid1"
							style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH: 100%; WORD-BREAK: break-all; BORDER-BOTTOM: gray 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #f5fafe; WORD-WRAP: break-word">
							<tr
								style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #FFE4C4">

								<td align="center" width="6%">序号</td>
								<td align="center" width="7%">用户昵称</td>
								<td align="center" width="17%">留言</td>
								<td align="center" width="17%">商家回复</td>
								<td align="center" width="14%">留言日期</td>
								<td align="center" width="10%">留言操作</td>

							</tr>
							<c:forEach items="${pageBean.list}" var="message"> 
								<tr onmouseover="this.style.backgroundColor = 'white'"
									onmouseout="this.style.backgroundColor = '#F5FAFE';" id="tr_${message.messageid }">
									<td style="CURSOR: hand; HEIGHT: 22px" align="center"
										width="6%"><input name="ids" value="${message.messageid}" type="checkbox" /></td>

									<td style="CURSOR: hand; HEIGHT: 22px" align="center"
										width="7%">${message.user.username}
									</td>
									<td style="CURSOR: hand; HEIGHT: 22px" align="center"
										width="17%"><strong><font color="red">${message.message}
										</font>
									</strong></td>
									<td style="CURSOR: hand; HEIGHT: 22px" align="center"
										width="17%"><strong><font color="red">${message.reply}
										</font>
									</strong></td>
									<td style="CURSOR: hand; HEIGHT: 22px" align="center"
										width="14%">${message.messagedate}
									 </td>
									 <td style="CURSOR: hand; HEIGHT: 22px" align="center"
										width="10%"><a href="${ pageContext.request.contextPath }/delmessage.action?mid=${message.messageid}"  onclick="return checkDel();">删除</a>
									 </td>
								</tr>
							</c:forEach>
						</table></td>
				</tr>
				<tr align="center">
					
					<td colspan="7">
					<div  align="left">
					<a href="${pageContext.request.contextPath}/messageList.action?page=1" style="color: red;" >全部留言板</a>
				 	  |
					<a href="${pageContext.request.contextPath}/mymessageList.action?page=1" style="color: red;" >我的留言板</a> |
					<input id="deleteSkills" type="button" value="-批量删除-" onclick="chooseShip()" 
			style="color:#fff;background-color: #d9534f;border-color: #d9534f;margin-left:710px;margin-top:10px;margin-bottom:10px;"/>
					</div>
					<div class="pagination">
					
								<span>第${pageBean.page}/${pageBean.totlePage}页</span>
								<c:if test="${pageBean.page!=1}">
									<a href="${ pageContext.request.contextPath }/mymessageList.action?page=1" class="firstPage">&nbsp;</a>
									<a
										href="${ pageContext.request.contextPath }/mymessageList.action?page=${pageBean.page-1}"
										class="previousPage">&nbsp;</a>
								</c:if>
								<c:forEach var="i" begin="1" end="${pageBean.totlePage}">
									<c:choose>
										<c:when test="${pageBean.page!=i}">
											<a
												href="${pageContext.request.contextPath }/mymessageList.action?page=${i}">
												${i}
											</a>
										</c:when>
										<c:otherwise>
											<span class="currentPage">${i}</span>
										</c:otherwise>
									</c:choose>
								</c:forEach>
								<c:if test="${pageBean.page!=pageBean.totlePage}">
									<a class="nextPage"
										href="${ pageContext.request.contextPath }/mymessageList.action?page=${pageBean.page+1}">&nbsp;</a>
									<a class="lastPage"
										href="${ pageContext.request.contextPath }/mymessageList.action?page=${pageBean.totlePage}">&nbsp;</a>
								</c:if>
							</div>
					</td>
				</tr>
				<tr>
				<td colspan="7">
					<form action="${ pageContext.request.contextPath }/saveMessage.action" method="post">
				    	<textarea rows="10" cols="10" id="messageinfo" name="messageinfo"></textarea>  
				    	<ck:replace replace="messageinfo" basePath="ckeditor"></ck:replace>  
				    	<input type="submit" value="发表留言"></input>
				    </form>
				</td>
				</tr>
		</table>
	</div>

	<div class="container footer">
		<div class="span24">
			
		</div>
		<div class="span24">
			<ul class="bottomNav">
				<li><hr></hr></li>
			</ul>
		</div>
		<div class="span24">
			<div class="copyright">Copyright © 网上商城 版权所有</div>
		</div>
	</div>
</body>
</html>